<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
// 网站地址
String netPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
%>
<%
       //读取硬盘上的Cookie
       Cookie cookies[]=request.getCookies();
       Cookie myCookie=null;
       String ckName=null;
       String ckValue="";
       //遍历cookie
       if(cookies!=null){
           for(int i=0;i<cookies.length-1;i++){
	            myCookie=cookies[i];
	            //获取对应cookie的名字 keepName 
	            ckName=myCookie.getName();
	            if("keepName".equals(ckName)){
		            //获取cookie的值
		            ckValue=myCookie.getValue();
		            break;
	            }
           }
       }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equivmetahttp-equiv="x-ua-compatible"content="IE=7"/> 
<title>黑龙江省大学生创业服务频道管理系统</title>
<link rel="shortcut icon" href="<%=basePath%>/favicon.ico" />
<link href="<c:url value="/stylesheets/login.css"/>" rel="stylesheet" type="text/css" />
<script  src="<c:url value="/javascripts/jquery_zip.js"/>"></script>
<script  src="<c:url value="/javascripts/jquery.placeholder.js"/>"></script>
<script type="text/javascript">
	function dosubmit(obj){
		if(validateSubmit()){
			$(obj).attr("disabled","true");
			saveUserCodeAndPassword();
			$("form.login-form").submit();
		}
	}
	function saveUserCodeAndPassword(){
		//if($("[name=keepName]").attr("checked")==="checked"){
		if($("[name=keepName]").attr("checked")){
			var userName = $("[name=name]").val();
			alert(userName);
			var password = $("[name=password]").val();
			alert(password);
			if(userName&&password){
				SetCookie("userName",userName);
				//SetCookie("password",password);
			}
		}
	}
	function validateSubmit(){
		$(".point1 > p").addClass("hidden");
		var message = "";
		if($("#name").val().length<1){
			message+="账号不能为空！\n";
		}
		if($("#password").val().length<1){
			message+="密码不能为空！\n";
		}
		/* if($("#verificationCode").val().length<1){
			message+="验证码不能为空！\n";
		} */
		if(message.length>5){
			alert(message);
			return false;
		}
		return true;
	}
	function changeVerificationCode(){
		var img=document.getElementById("verificationCodeImg");
		img.src=img.src+"?";
	}
	
	$(document).ready(function(e) {
 	    $('input').placeholder();	
			$('[name=keepName]').click(function(){
				$('.point2 p').toggle(this.checked);
		});
		var userName = 	GetCookie("userName");
		var password =  GetCookie("password");
/* 		$("#name").val(userName);
		$("#password").val("");  */
		$("#name").val("");
		$("#password").val("");
  	});
	
	function GetCookie (name){ 
		var arg = name + "="; 
		var alen = arg.length; 
		var clen = window.document.cookie.length; 
		var i = 0; 
		while (i < clen) { 
			var j = i + alen; 
			if (window.document.cookie.substring(i, j) == arg) 
				return getCookieVal (j); 
			i = window.document.cookie.indexOf(" ", i) + 1; 
			if (i == 0)
				break; 
		} 
		return null;
    }
    function getCookieVal (offset){ 
		var endstr = window.document.cookie.indexOf (";", offset); 
		if (endstr == -1)
			endstr = window.document.cookie.length; 
		return unescape(window.document.cookie.substring(offset, endstr));
    }
    function SetCookie (name, value){ 
		var exp = new Date(); 
		exp.setTime(exp.getTime() + (30*24*60*60*1000));
		window.document.cookie = name + "=" + escape (value) + "; expires=" + exp.toGMTString()+"; ";
    }
    
    // 回车提交表单
    function enterSubmit(e){
		var charCode=(navigator.appName=="Netscape")?e.which:e.keyCode;
    	if(charCode==13){
    		if(validateSubmit()){
				saveUserCodeAndPassword();
				$("form.login-form").submit();
			}
    	}
    };
    // 重置
    function resetInput(){
    	$("#name").val("");
    	$("#password").val("");
    }
</script>
</head>

<body>
<div id="header"><div>
<h1>黑龙江省大学生创业服务频道-后台管理</h1>
<!-- <img src="<%=basePath%>images/login_logo.gif" /> -->
</div></div>
<div class="out"><div id="content">
   <div class="panel">
   <form class="form-horizontal login-form" action="<c:url value="/account/login"/>" method="post">
    <c:choose>
    	<c:when test="${message != null}">
		    <div class="point1">
		      <p><img src="<%=basePath%>images/error.gif" />${message}</p>
		    </div>
    	</c:when>
    	<c:otherwise>
		    <div class="point1">
		      <p class="hidden"><img src="<%=basePath%>images/error.gif" /></p>
		    </div>
    	</c:otherwise>
    </c:choose>
    <p>
    	<input type="text" id="name" name="name"  placeholder="请输入账号" value="" onkeydown="enterSubmit(event)"/>
    </p>
    <p>
    	<input type="password" id="password" name="password" placeholder="请输入密码" value="" onkeydown="enterSubmit(event)"/>
    </p>
    <%-- <p><input type="text" id="verificationCode" name="verificationCode" placeholder="请输入验证码" class="code_input" onkeydown="enterSubmit(event)"/>
    <span class="pincode"><img src="<c:url value="/servlet/random"/>" id="verificationCodeImg" alt="验证码" style="vertical-align:middle" /><a href="javascript:void(0);"  onclick="changeVerificationCode();">换一张</a></span>
    </p> --%>
	<!-- <div class="keep">
    <input name="keepName" type="checkbox" value="keep"/>记住账号</div> -->
	<div class="point2"><p class="hidden">为了账户安全，请勿在公用电脑上勾选此项。</p></div>
    <p class="btn"><img src="<%=basePath%>images/dl.gif" onclick="dosubmit(this)"/><a href="#" style="margin-left:0px" onclick="resetInput();"><img src="<%=basePath%>images/lx.gif" class="lx" style="width: 147px;height: 34px;"/></a></p>
    </form>
	<p class="company center">黑龙江省大学生创业服务频道</p>
   </div>
  </div>
  </div>
<div id="footer"><img src="<%=basePath%>images/footer.gif" /><p>黑龙江省大学生创业服务频道
</p></div>



</body>
</html>
